//
//  WBWelcomeView.m
//  TransWB
//
//  Created by 孝飞王 on 2017/1/17.
//  Copyright © 2017年 孝飞王. All rights reserved.
//

#import "WBWelcomeView.h"
#import "UIImageView+WebCache.h"

@interface WBWelcomeView()
@property (weak, nonatomic) IBOutlet UIImageView *avatar_imageView;
@property (weak, nonatomic) IBOutlet NSLayoutConstraint *avatar_cons;
@property (weak, nonatomic) IBOutlet NSLayoutConstraint *avatar_buttom_cons;
@property (weak, nonatomic) IBOutlet UILabel *welcom_label;


@end

@implementation WBWelcomeView

+ (WBWelcomeView *)welcomeView{
    
    UINib *nib = [UINib nibWithNibName:@"WBWelcomeView" bundle:nil];
    WBWelcomeView *welcomeView = [nib instantiateWithOwner:nil options:nil][0];
    welcomeView.backgroundColor = [UIColor greenColor];
    
    return welcomeView;
}

- (void)awakeFromNib{
    [super awakeFromNib];
    
    self.avatar_imageView.layer.cornerRadius = self.avatar_cons.constant / 2 ;
    self.avatar_imageView.clipsToBounds =  YES;
    
    if (![WBNetworkManager shareManager].isLogin)  return;
    
    [self.avatar_imageView sd_setImageWithURL:
                                                [NSURL URLWithString:[WBNetworkManager shareManager].userAccount.avatar_large]
                                                placeholderImage:[UIImage imageNamed:@"avatar_default_big"]];
    
}

- (void)didMoveToWindow{
    [super didMoveToWindow];
    
    //加载欢迎动画
    [self layoutIfNeeded];
    self.avatar_buttom_cons.constant = Screen_Height - 200;
    
    [UIView animateWithDuration:1.f delay:0 usingSpringWithDamping:0.7 initialSpringVelocity:0 options:0 animations:^{
        
        [self layoutIfNeeded];
        
    } completion:^(BOOL finished) {
        
        [UIView animateWithDuration:1.f animations:^{
        
            self.welcom_label.alpha = 1;
        } completion:^(BOOL finished) {
        
            [self removeFromSuperview];
        }];
        
    }];
    
    
}









@end
